package Frame.battleanimation;

import static FCRendering.FCRMaster.fcv;

public class AnimationUtil {

    public static double getDistance(int[] start, int[] end) {
        return Math.sqrt((end[0] - start[0]) * (end[0] - start[0]) + (end[1] - start[1]) * (end[1] - start[1]));
    }


    /**
     * @param start
     * @param end
     * @param per   帧数百分比，1就是走到终点了
     * @return
     */
    public static void getAnimatePoint(int[] set, int[] start, int[] end, float per) {
        set[0] = (int) (start[0] + (end[0] - start[0]) * per);
        set[1] = (int) (start[1] + (end[1] - start[1]) * per);
    }

    /**
     * 抛物线
     *不行
     * @param set
     * @param start
     * @param end
     * @param per
     */
    public static void getThrowAnimatePoint(int[] set, int[] start, int[] end, float per) {
        set[0] = (int) (start[0] + (end[0] - start[0]) * per);
        set[1] = (int) (start[1] + (end[1] - start[1]) * per);
        float h = (float) (100 * fcv.getProportion());
        float dy = 0;
        if (per <= 0.4) {
            dy = (int) (Math.sqrt(per*h*h/0.4));
        } else {
            float vh = (float) (h/(1+0.4*0.4));
            dy = (int) ((1-per*per)*vh);
        }
        set[1] -= dy;

    }
}
